package resources;

public class Bishops

{
	//**************************************************************************
	// *   Copyright (C) 2008 by Liu Kaipeng                                     *
	// *   LiuKaipeng at gmail dot com                                           *
	// **************************************************************************

	// @JUDGE_ID 00000 861 C++ "Little Bishops" 

	public static long bishops(int n, int k)
	{
	  long[] r1 = new long[9];
	  long[] r2 = new long[9];
	  for (int i = 1; i <= n; ++i)
		r1[i] = i % 2 != 0 ? i : r1[i-1];
	  
	  for (int i = 1; i <= n-1; ++i)
		r2[i] = i % 2 != 0 ? i+1 : r2[i-1];
	  
	  long[][] c1 = {{0}};
	  long[][] c2 = {{0}};
	  for (int i = 0; i <= n; ++i)
		c1[i][0] = 1;
	  for (int j = 1; j <= k; ++j)
		c1[0][j] = 0;
	  for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= k && j <= i; ++j)
		  c1[i][j] = c1[i-1][j] + c1[i-1][j-1]*(r1[i] - j + 1);

	  for (int i = 0; i <= n-1; ++i)
		c2[i][0] = 1;
	  for (int j = 1; j <= k; ++j)
		c2[0][j] = 0;
	  for (int i = 1; i <= n-1; ++i)
		for (int j = 1; j <= k && j <= i; ++j)
		  c2[i][j] = c2[i-1][j] + c2[i-1][j-1]*(r2[i] - j + 1);

	  long r = 0;
	  for (int i = 0; i <= k; ++i)
		r += c1[n][i] * c2[n-1][k-i];
	  return r;
	}
	public static void main(String[] args)
	{
		System.out.print(bishops(4, 4));
		System.out.print("\n");
	
	}
}
